# $Id: PKGBUILD 178751 2013-02-26 16:43:34Z pierre $
# Maintainer: Jan de Groot <jgc@archlinux.org>

pkgname=ca-certificates-java
pkgver=20121112+nmu2
pkgrel=1
pkgdesc='Common CA certificates (JKS keystore)'
arch=('any')
url='http://packages.qa.debian.org/c/ca-certificates-java.html'
license=('GPL')
depends=('ca-certificates')
makedepends=('jdk7-openjdk')
checkdepends=('junit')
install='ca-certificates-java.install'
backup=('etc/default/cacerts')
source=("http://ftp.debian.org/debian/pool/main/c/${pkgname}/${pkgname}_${pkgver}.tar.gz"
        'init-jks-keystore' 'jks-keystore.hook')
md5sums=('9562403f0cc9300d29af5b8baa9ddeab'
         '75eeca3f443f4b5a17ed5ac81875f1e9'
         '6dd4f915aee0df51260083e00b7fa012')

build() {
	cd ${srcdir}/${pkgname}-${pkgver}
	javac -target 1.6 -source 1.6 UpdateCertificates.java
	jar cfe ca-certificates-java.jar UpdateCertificates *.class
}

check() {
	cd ${srcdir}/${pkgname}-${pkgver}

	javac -cp /usr/share/java/junit.jar:/usr/share/ca-certificates-java/ca-certificates-java.jar \
		UpdateCertificatesTest.java Exceptions.java
	java -cp /usr/share/java/junit.jar:/usr/share/ca-certificates-java/ca-certificates-java.jar:. \
		org.junit.runner.JUnitCore \
		UpdateCertificatesTest
}

package() {
	cd ${srcdir}/${pkgname}-${pkgver}

	install -d -m755 ${pkgdir}/etc/ssl/certs/java
	install -D -m600 debian/default ${pkgdir}/etc/default/cacerts
	install -D -m644 ca-certificates-java.jar ${pkgdir}/usr/share/ca-certificates-java/ca-certificates-java.jar
	install -D -m755 ${srcdir}/init-jks-keystore ${pkgdir}/usr/sbin/init-jks-keystore
	install -D -m755 ${srcdir}/jks-keystore.hook ${pkgdir}/etc/ca-certificates/update.d/jks-keystore
}
